<?php

class String
{

  private $string;

  public function __construct($string)
  {
    $this->string = $string;
  }

  public function __toString()
  {
    return $this->string;
  }

  public function Prepend($string)
  {
    $this->string = $string . $this->string;
  }

  public function Append($string)
  {
    $this->string .= $string;
  }

  public function StartWith($needle)
  {
    return !strncmp($this->string, $needle, strlen($needle));
  }

  public function EndWith($needle)
  {
    $length = strlen($needle);
    if ($length == 0) {
      return true;
    }

    return (substr($this->string, -$length) === $needle);
  }

  public function ToLower()
  {
    return strtolower($this->string);
  }

  public function ToUpper()
  {
    return strtoupper($this->string);
  }
}
